package lyttest.common.redisConnect;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.Set;

public class ClusterRedisConnection implements RedisConnection {
    private final JedisCluster jedisCluster;

    public ClusterRedisConnection(Set<HostAndPort> nodes) {
        this.jedisCluster = new JedisCluster(nodes);
    }

    @Override
    public String set(String key, String value) {
        return jedisCluster.set(key, value);
    }

    @Override
    public boolean getBit(String key, Integer offset) {
        return jedisCluster.getbit(key, offset);
    }

    @Override
    public void close() {
        if (jedisCluster != null) {
            jedisCluster.close();
        }
    }
}